///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////

#ifndef __STRINGS_H__
#define __STRINGS_H__

#include "Core/Commons.h"
#include "irrTypes.h"
#include "irrArray.h"

//using namespace irr;
///////////////////////////////////////////////////////////////////////////////
class CBinaryFile;

class CStrings
{
public:
	CStrings();
	~CStrings();

	void InitMemory( irr::u32 buffer_size, irr::u16 nStrings );
	void FreeMemory( );

	 //void ConvertEndian();

	 bool IsPackLoaded( int nFileIndex ) { return s_nFileIndex == nFileIndex; }

	 int LoadStringPack(CBinaryFile* stringsFile , CBinaryFile* stringsOffset);
	 int LoadStringMap(CBinaryFile* mapFile);

	 int LoadData(CBinaryFile* stringsFile);
	 int LoadDataMap(CBinaryFile* mapFile);

	 void ClearStringTable();
	
	 GX_CHAR* GetString( int id );

	 int GetStringIdFromName(const char* strName);
	
	 void ClearMap();
private :	 
	 int				s_nFileIndex;
	 irr::u16			s_nNumberOfStrings;
     GX_CHAR*			s_pStringsBuffer;
     irr::u32*			s_aOffsets;
	 irr::u32			s_nStringsLen;

	 irr::core::array<GX_CHAR*>	m_strMap;

private:
	int			m_nStrings;	//Number of strings in the pack
	unsigned int		*	m_pOffsets;	//Offset for each string in m_pData(pointer only)
	GX_CHAR	*	m_pData;	//String pack data (pointer only)
	irr::u8	*		m_pBuffer;	//The file buffer of the string pack

	char*		m_pMapBuffer;
	irr::core::array<char*>	m_dataMap;
};

///////////////////////////////////////////////////////////////////////////////

//char* ToUpperCase( char* str );
//char* Capitelize( char* str );
//void GetMoneyString( int nMoney, wchar_t* pBuffer ,wchar_t* pPrefix = NULL, wchar_t* pSuffix = NULL  );
///////////////////////////////////////////////////////////////////////////////

#endif //__STRINGS_H__

///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
